#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>


  struct ListNode {
      int val;
      struct ListNode *next;
  };
 
struct ListNode* removeElements(struct ListNode* head, int val) {


    struct ListNode* pre = (struct ListNode*)malloc(sizeof(struct ListNode));
    pre->next = head;
    struct ListNode* tail = pre;
    while (tail->next != NULL)
    {
        if (tail->next->val == val)
        {

            tail->next = tail->next->next;
        }
        else
        {
            tail = tail->next;
        }

    }
    return pre->next;
}